#include "mythread.h"

MyThread::MyThread(QObject *parent) : QThread(parent)
{
    isRun = true;

}
void MyThread::run(){

    while(isRun){
        //等待2秒
        QThread::sleep(2);
        qDebug()<<"MyThread子线程号:"<<QThread::currentThreadId();
        //发送子线程 信号
        emit isDone();
    }
    //释放线程资源
    MyThread::quit();
    MyThread::wait();
}

void MyThread::setFlag(bool flag){
    isRun=flag;
}
bool MyThread::getFlag(){
    return isRun;
}
MyThread::~MyThread(){

}
